﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace BaseAttack
{
    public class U
    {
        public static double Distance(Point p1, Point p2)
        {
            return Math.Sqrt(((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)));
        }

        public static Unit GetUnitAt(Point p, List<Unit> Units)
        {
            return GetUnitAt(p, Units, false);
        }

        public static Unit GetUnitAt(Point p, List<Unit> Units, Boolean ReverseOrder)
        {
            if (ReverseOrder)
            {
                Units = new List<Unit>(Units);
                Units.Reverse();
            }
            foreach (Unit u in Units)
            {
                if (u.HitTest(p))
                {
                    return u;
                }
            }
            return null;
        }

    }
}
